//
// Created by lenovo on 2023/12/24.
//
#include<bits/stdc++.h>
using namespace std;
long long arr[30004];
int main()
{
   int  w = 0, n = 0, ans = 0;
    cin >> w >> n;
    for(int  i = 0;i < n;i++){
        cin >> arr[i];
    }
    sort(arr , arr + n);
    int l = 0, r= n - 1;
    while(l <= r)
    {
        if(arr[l] + arr[r] <= w)
        {
            ans++;
            l++;
            r--;
        }
        else{
            ans++;
            r--;
        }
    }
    cout << ans;
    return 0;
}